home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_8 / issue_07 / std / !STDFinder / c / windcodes < prev   
Encoding:
Text File  |  1993-06-12  |  17.9 KB  |  686 lines

  1. /* Title:   windcodes.c
  2.  * Purpose: Allow searching of STD codes or towns 
  3.  * Author:  Julyan Bristow
  4.  * Date:    August 1992 - February 1993
  5.  */
  6. #include "wimp.h"
  7. #include "wimpt.h"
  8. #include "win.h"
  9. #include "event.h"
  10. #include "baricon.h"
  11. #include "res.h"
  12. #include "resspr.h"
  13. #include "menu.h"
  14. #include "template.h"
  15. #include "dbox.h"
  16. #include "werr.h"
  17. #include "bbc.h"
  18. #include "visdelay.h"
  19. #include "saveas.h"
  20. #include "xfersend.h"
  21. #include "xferrecv.h"
  22. #include "akbd.h"
  23. #include "coords.h"
  24.  
  25. #include "stdio.h"
  26. #include "stdlib.h"
  27. #include "string.h"
  28. #include "ctype.h"
  29. /********************************* CONSTANTS ********************************/
  30. #define icon_m_i      1
  31. #define icon_m_srch   2
  32. #define icon_m_q      3
  33. #define srch_m_e      1
  34. #define srch_m_s      2
  35. #define save_m_a      1
  36. #define save_m_s      2
  37. #define edit_m_a      1
  38. #define edit_m_d      2
  39. #define Author_field  3
  40. #define Info_version  4
  41. #define Data_file      "<STDFinder$Dir>.Directorys.STDCodes"
  42. #define Data_file_name "stdcodes"
  43. #define tft           0xfff
  44. #define fmnl          256
  45. #define mtnl          50
  46. #define mcl           8
  47. #define akbd_return   0x0d
  48. #define winmargin     8
  49. #define LINEHT        32
  50. /******************************** GLOBAL DATA *******************************/
  51. static char *Version = "2.00 (12 June 1993)";
  52. static char *Author = "Julyan Bristow";
  53. char *pathname;
  54.  
  55. static menu iconbar_menu,search_menu,save_menu,edit_menu;
  56. static dbox search_box,edit_box,quit_box,load_box;
  57. static wimp_w wintext_handle;  /* wimp_w being an abstract window handle */
  58. static wimp_w search_handle;
  59.  
  60. static BOOL win_open = FALSE;
  61. static BOOL search_box_open = FALSE;
  62. static enum {search_entry = 1,srch_srch,srch_cancel,srch_clear,srch_sh_town,
  63.              srch_sh_code,u_arrow,d_arrow,search_exact_option = 10 };
  64. static enum {e_town = 0,e_code,e_ok};
  65. static enum {q_dis = 4,q_save,q_can};
  66. static enum {l_over = 4,l_app,l_can};
  67.  
  68. int maximum,all;
  69. static int found = 0;
  70. int modified = 0,edit = 0;
  71. int initialise = 1;
  72. int offset = 0;
  73. /***************** Define the structures for the towns and codes ****************/
  74.   struct std {
  75.     char town[mtnl];
  76.     char code[mcl];
  77.     struct std *next;
  78.     struct std *previous;
  79.     } *stdstart,*stdlast,*stdnode;  
  80.   struct search {
  81.     char town[mtnl];
  82.     char code[mcl];
  83.     struct search *next;
  84.     struct search *previous;
  85.     } *srchstart,*srchlast,*s_node;
  86.   
  87. /***************** Define the external routines ***************************/
  88. FILE *data_file;
  89. FILE *file_open(char *open_name,char *mode);
  90. void file_close(FILE *close_stream, char *close_name);
  91. int file_read(FILE *from_file,char *read_name,int action);
  92. int initial_file_read(FILE *from_file,char *read_name,int action);
  93. int string_search(char *search_for,int search_exact);
  94. char *string_to_lower(char *string);
  95.  
  96. static BOOL export_as_text(char *filename,void *handle)
  97. {
  98.   FILE *f;
  99.   BOOL ok = TRUE;
  100.   char ch;
  101.   struct std *std_node;
  102.   struct search *s_node;
  103.   if (strlen(filename) > fmnl) {
  104.     werr(0,"Filename is too long");
  105.     return(FALSE);
  106.   }
  107.   f=fopen(filename,"w");
  108.   if (f==0) { ok = FALSE; werr(0,"Cannot open file"); }
  109.   else {
  110.   maximum += 2;
  111.   ch = ' ';
  112.     if (all == 1) {
  113.       std_node = stdstart;
  114.       while (std_node) {
  115.       fprintf(f,"%-*s%c%-6s\n",maximum,std_node->town,ch,std_node->code);
  116.       std_node = std_node->next;
  117.       }
  118.     }
  119.     if (all == 2) {
  120.       std_node = stdstart;
  121.       while (std_node) {
  122.       fprintf(f,"%s,%s\n",std_node->town,std_node->code);
  123.       std_node = std_node->next;
  124.       }
  125.     }
  126.     if (all == 0) {
  127.       s_node = srchstart;
  128.       while (s_node) {
  129.       fprintf(f,"%-*s%c%-6s\n",maximum,s_node->town,ch,s_node->code);
  130.       s_node = s_node->next;
  131.       }
  132.     }
  133.   }
  134.   fclose(f);
  135.   maximum -= 2; /* reset value of maximum */
  136.   return(ok);
  137. }
  138. void window_tidy(char *window_name)
  139. {    
  140.   if (!strcmp(window_name,"search")) {
  141.     search_box_open = TRUE;
  142.     dbox_setfield(search_box,search_entry,"");
  143.     }
  144. }
  145. static void save_menuproc(char *hit)
  146. {
  147.   switch (hit[1])
  148.   {
  149.     case save_m_a:
  150.     all = 1;
  151.     saveas(tft,"<STDFinder$Dir>.All",0,export_as_text,0,0,0);
  152.     break;
  153.     case save_m_s: 
  154.     all = 0;
  155.     saveas(tft,"<STDFinder$Dir>.Subset",0,export_as_text,0,0,0);
  156.     break;
  157.     }
  158. }
  159. static void edit_menuproc(char *hit)
  160. {
  161.   switch (hit[1])
  162.   {
  163.   case edit_m_a:
  164.     edit = 0; /* 0 = add */
  165.     dbox_setfield(edit_box,e_town,"");
  166.     dbox_setfield(edit_box,e_code,"");
  167.     dbox_showstatic(edit_box);
  168.     break;
  169.   case edit_m_d:
  170.     edit = 1; /* 1 = delete */
  171.     dbox_setfield(edit_box,e_town,"");
  172.     dbox_setfield(edit_box,e_code,"");
  173.     dbox_showstatic(edit_box);
  174.     break;
  175.   }
  176. }
  177. static void search_menuproc(void *handle, char *hit)
  178. {
  179.   handle = handle; 
  180.   switch (hit[0])
  181.   {
  182.   case srch_m_e:
  183.     edit_menuproc(hit);
  184.     break;
  185.   case srch_m_s:
  186.     save_menuproc(hit);
  187.     break;
  188.   }
  189. }
  190. /***************************** WINDOW FUNCTIONS *****************************/
  191. int win_lines(void)
  192. {
  193. wimp_wstate s;
  194.   wimpt_noerr(wimp_get_wind_state(wintext_handle, &s));
  195.   return (s.o.box.y1 - s.o.box.y0 - 2 * winmargin) / 32;
  196. }
  197. void wrele(FILE *out,int n) 
  198. {
  199. int i;
  200. s_node = srchstart;
  201.   if(!n) {
  202.     fprintf(out,"%-*s%-8s\n",maximum,"Town","STD Code");
  203.     return;
  204.     }
  205.   if (n > 1) {
  206.   for (i=1;i<n;i++) {
  207.       if(!s_node->next) return;
  208.       else s_node = s_node->next;
  209.       }
  210.   }
  211.   fprintf(out, "%-*s%-8s\n",maximum,s_node->town,s_node->code);
  212. }
  213. /*--- Create the window, yielding its handle. Return TRUE if ok. ---*/
  214. static BOOL create_window(char *name, wimp_w *handle)
  215. {
  216.   int height;
  217.   wimp_wind *window;    /* Pointer of type window definition in this function */
  218.  
  219.   wimp_wstate  boxstatus;  /* variable of type wimp_state - contains info about position, size etc of window */
  220.   wimp_openstr boxopen;
  221.  
  222.   wimpt_complain(wimp_get_wind_state(search_handle, &boxstatus));
  223.   boxopen = boxstatus.o;
  224.  
  225.   window = template_syshandle(name);
  226.   if (window == 0) return FALSE;
  227.   window->title.indirecttext.buffer = "Search Results";    /* create the title of the window */
  228.  
  229. /*  if (found > 20) height = 20;*/
  230.   height = found;
  231.   window->box.x0 = boxopen.box.x0;
  232.   window->box.x1 = boxopen.box.x0 + 16 * (maximum + mcl + 2);
  233.   window->box.y1 = boxopen.box.y0 - (8 * winmargin);
  234.   window->ex.y0  = -(((found + 1) * LINEHT) + winmargin);
  235.   window->ex.y1  = 0;
  236.   window->ex.x0  = 0;
  237.   window->ex.x1  = (maximum + strlen("STD Codes")) * 16;
  238.  
  239.   return (wimpt_complain(wimp_create_wind(window, handle)) == 0);
  240.  
  241. }
  242. static void wintext_open_window(wimp_openstr *o)
  243. {
  244.   /* Just pass the open request on to the wimp - called from the wimp_EOPEN event handler */
  245.   wimpt_noerr(wimp_open_wind(o));
  246. }
  247.  
  248. static void wintext_event_handler(wimp_eventstr *e, /*void *handle*/ void *lf)
  249. {
  250.   int more,bx,by,tl,bl;
  251.   int win_lines(void);
  252. /*  handle = handle; *//* We don't need handle (not sure why!): this stops compiler warning */
  253.   wimp_redrawstr *r;  /* pointer to a structure containing window area etc */
  254.  
  255.   switch (e->e) /* the first e is of type wimp_eventstr, which contains a structure of type wimp_etype e and of type wimpevent_data data */
  256.   {
  257.   case wimp_EREDRAW:
  258. /* wintext_redraw_window(e->data.o.w); */
  259.   
  260.   r = (wimp_redrawstr*)(&(e->data.o));
  261.   wimpt_noerr(wimp_redraw_wind(r, &more));
  262.   bx = r->box.x0 - r->scx;
  263.   by = r->box.y1 - r->scy;
  264.   while (more)   /* Do the redraw loop */
  265.   {
  266.     tl = (by - r->g.y1) / LINEHT;
  267.     if (tl < 0) tl = 0;
  268.        bl = (by - r->g.y0) / LINEHT;
  269.        if (bl > found) bl = found;
  270.        for(;tl <= bl; tl++) {
  271.          bbc_move(bx + winmargin, by - winmargin - (LINEHT * tl));
  272.          ((void(*)(FILE*,int))lf)(stdout,tl);
  273.          }
  274.   wimp_get_rectangle(r, &more);  /* redraw next rectangle until &more now reads FALSE */
  275.   } 
  276.       break;
  277.     case wimp_EOPEN:
  278.       wintext_open_window(&e->data.o);
  279.       win_open = TRUE;
  280.       break;
  281.     case wimp_ECLOSE:  /* Pass on close request */
  282.       wimpt_noerr(wimp_close_wind(e->data.o.w));
  283.       win_open = FALSE;
  284.       break;
  285.     case wimp_ESCROLL:
  286.     {
  287.     int dy = 0;
  288.       switch(e->data.scroll.y)
  289.       {
  290.       case  1:
  291.         dy =  1;  break;
  292.       case -1:
  293.         dy = -1;  break;
  294.       case  2:
  295.         dy = win_lines(); break;
  296.       case -2:
  297.         dy = -win_lines(); break;
  298.       }
  299.       e->data.scroll.o.y += dy * 32;
  300.     (void) wimpt_complain(wimp_open_wind(&e->data.scroll.o));
  301.     }
  302.   }
  303. }
  304. /************************* DIALOGUE BOX EVENT HANDLERS *************************/
  305. static void stdfinder_iconclick(wimp_i icon)
  306. {                       
  307.     if (search_box_open == FALSE) {
  308.       window_tidy("search");
  309.       dbox_showstatic(search_box);
  310.       dbox_setfield(search_box,search_entry,"");
  311.  
  312.       menu_setflags(save_menu,save_m_s,0,1);
  313.       found = 0;
  314.     }
  315. }
  316. static void stdcodes_info(void)
  317. {
  318.   dbox  d_info;
  319.   if (d_info = dbox_new("ProgInfo"), d_info != NULL)
  320.   {
  321.     dbox_setfield(d_info, Info_version, Version);
  322.     dbox_setfield(d_info, Author_field,Author);
  323.     dbox_show(d_info);
  324.     dbox_fillin(d_info);
  325.     dbox_dispose(&d_info);
  326.   }
  327. }
  328. static BOOL quit_event_handler(dbox edit_box,void *ev,void *handle)
  329. {
  330.   wimp_eventstr *e=(wimp_eventstr*) ev;
  331.   dbox_field field;
  332.   handle = handle;
  333.   switch (e->e)
  334.   {
  335.   case wimp_EOPEN:
  336.     wimpt_noerr(wimp_open_wind(&e->data.o));
  337.     break;
  338.   case wimp_ECLOSE:
  339.     dbox_hide(quit_box);
  340.     return(TRUE);
  341.     break;
  342.     case wimp_EBUT:
  343.     field = e->data.but.m.i;
  344.     switch (field)
  345.     {case q_dis:
  346.      exit(0);
  347.      break;
  348.      case q_save:
  349.      all = 2;
  350.      saveas(tft,Data_file,0,export_as_text,0,0,0);
  351.      exit(0);
  352.      break;
  353.      case q_can:
  354.      dbox_hide(quit_box);
  355.      break;
  356.      default:
  357.      break;
  358.     }
  359.   }
  360.   return (TRUE);
  361. }
  362. static BOOL load_event_handler(dbox load_box,void *ev,void *handle)
  363. {
  364.   wimp_eventstr *e=(wimp_eventstr*) ev;
  365.   int temp_max;
  366.   dbox_field field;
  367.   handle = handle;
  368.   switch (e->e)
  369.   { 
  370.   case wimp_EOPEN:
  371.     wimpt_noerr(wimp_open_wind(&e->data.o));
  372.     break;
  373.   case wimp_ECLOSE:
  374.     dbox_hide(load_box);
  375.     return(TRUE);
  376.     break;
  377.     case wimp_EBUT:
  378.     field = e->data.but.m.i;
  379.     switch (field)
  380.     {case l_over:
  381.      data_file = file_open(pathname,"r");
  382.      visdelay_begin();
  383.      temp_max = file_read(data_file,pathname,1);
  384.      if(temp_max > maximum) maximum = temp_max;
  385.      visdelay_end();
  386.      file_close(data_file,pathname);
  387.      dbox_hide(load_box);
  388.      if (win_open == TRUE) {
  389.      wimpt_noerr(wimp_close_wind(wintext_handle));
  390.      win_open = FALSE;
  391.      }
  392.      break;
  393.      case l_app:
  394.      data_file = file_open(pathname,"r");
  395.      visdelay_begin();
  396.      temp_max = file_read(data_file,pathname,0);
  397.      if(temp_max > maximum) maximum = temp_max;
  398.      visdelay_end();
  399.      file_close(data_file,pathname);
  400.      dbox_hide(load_box);
  401.      if (win_open == TRUE) {
  402.      wimpt_noerr(wimp_close_wind(wintext_handle));
  403.      win_open = FALSE;
  404.      }
  405.      break;
  406.      case l_can:
  407.      dbox_hide(load_box);
  408.      break;
  409.      default:
  410.      break;
  411.     }
  412.   }
  413.   return (TRUE);
  414. }
  415. static BOOL edit_event_handler(dbox load_box,void *ev,void *handle)
  416. {
  417.   char town[mtnl],code[mcl];
  418.   void add_entry(char *town,char *code);
  419.   void delete_entry(char *town,char *code);
  420.   wimp_eventstr *e=(wimp_eventstr*) ev;
  421.   dbox_field field;
  422.   handle = handle;
  423.   switch (e->e)
  424.   {
  425.   case wimp_EOPEN:
  426.     wimpt_noerr(wimp_open_wind(&e->data.o));
  427.     break;
  428.   case wimp_ECLOSE:
  429.     dbox_hide(edit_box);
  430.     return(TRUE);
  431.     break;
  432.    case wimp_EBUT:
  433.     field = e->data.but.m.i;
  434.     switch (field)
  435.     {case e_ok:
  436.      dbox_getfield(edit_box,e_town,town,mtnl-1);
  437.      dbox_getfield(edit_box,e_code,code,mcl-1);
  438.      if (!strlen(town) || !strlen(code)) {
  439.        werr(0,"Incomplete data entry. Please try again.");
  440.        break;
  441.        }
  442.      if (edit == 0) {
  443.        add_entry(town,code);
  444.        dbox_hide(edit_box);
  445.        dbox_setfield(search_box,search_entry,"");
  446.        break;
  447.        }
  448.      else {
  449.        delete_entry(town,code);
  450.        dbox_hide(edit_box);
  451.        dbox_setfield(search_box,srch_sh_code,"");
  452.        break;
  453.      }
  454.      default:
  455.      break;
  456.     }
  457.   }
  458.   return (TRUE);
  459. }
  460. int start_search(int exact)
  461. {
  462.   char search_string[mtnl];
  463.   if (win_open == TRUE) { wimpt_noerr(wimp_close_wind(wintext_handle)); win_open = FALSE; }
  464.   dbox_getfield(search_box,search_entry,search_string,79);
  465.   found = string_search(search_string,exact);
  466.   if (found) {
  467.     wimp_wstate  winstatus;  /* variable of type wimp_state - contains info about position, size etc of window */
  468.     wimp_openstr wopen;
  469.  
  470.     s_node = srchstart;
  471.     menu_setflags(save_menu, save_m_s, 0, 0);
  472.  
  473.    /* Create the main window, and declare its event handler */
  474.    if (!create_window("Main", &wintext_handle))  return FALSE; /* Window creation failed */
  475.     win_register_event_handler(wintext_handle, wintext_event_handler, (void*)wrele);
  476.     event_attachmenu(wintext_handle,search_menu,search_menuproc,0);
  477.  
  478.     /* Get the state of the window - pass window's handle (global) and the determined status */
  479.     wimpt_complain(wimp_get_wind_state(wintext_handle, &winstatus));
  480.     wopen = winstatus.o;
  481.  
  482.     wopen.behind = -1;          /* Make sure window is opened in front using this bit from the structure */
  483.  
  484.     wimpt_noerr(wimp_open_wind(&wopen));  /* in this line could have also used winstatus.o as these are the same */
  485.     win_open = TRUE;
  486.     offset = 0;
  487.     wintext_open_window(&wopen);
  488.  
  489.     return found;
  490.     }
  491.   else {
  492.     bbc_vdu(7);
  493.     menu_setflags(save_menu, save_m_s, 0, 1);
  494.     return NULL;
  495.     win_open = FALSE;
  496.     }
  497. }
  498. static BOOL search_event_handler(dbox search_box,void *ev,void *handle)
  499. {
  500.   static int exact = 0;
  501.   char search_string[mtnl];
  502.   wimp_eventstr *e=(wimp_eventstr*) ev;
  503.   dbox_field field;
  504.   handle = handle;
  505.   switch (e->e)
  506.   {case wimp_ECLOSE:
  507.       dbox_hide(search_box);
  508.       dbox_hide(edit_box);
  509.       search_box_open = FALSE;
  510.       if (win_open) {
  511.       wimpt_noerr(wimp_close_wind(wintext_handle));
  512.       win_open = FALSE;
  513.       }
  514.       return(TRUE);
  515.       break;
  516.     case wimp_EKEY:
  517.       switch (e->data.key.chcode) {
  518.         case (akbd_return) :
  519.           found = start_search(exact);
  520.           s_node = srchstart;
  521.           break;
  522.         default:
  523.           break;
  524.       }
  525.       break;
  526.    case wimp_EBUT:
  527.       field = e->data.but.m.i;
  528.       switch (field)
  529.       {case srch_srch:
  530.           found = start_search(exact);
  531.           s_node = srchstart;
  532.           break;
  533.        case srch_clear:
  534.           strcpy(search_string,"");
  535.           dbox_setfield(search_box,search_entry,search_string);
  536.           menu_setflags(save_menu,save_m_s,0,1);
  537.           if (win_open) {
  538.           wimpt_noerr(wimp_close_wind(wintext_handle));
  539.           win_open = FALSE;
  540.           }
  541.           found = 0;
  542.           break;
  543.        case srch_cancel:
  544.           dbox_hide(search_box);
  545.           dbox_hide(edit_box);
  546.           search_box_open = FALSE;
  547.           menu_setflags(save_menu,save_m_s,0,1);
  548.           if (win_open) {
  549.             wimpt_noerr(wimp_close_wind(wintext_handle));
  550.             win_open = FALSE;
  551.             }
  552.           found = 0;
  553.           break;
  554.        case search_exact_option:
  555.           exact = dbox_getnumeric(search_box,search_exact_option);
  556.           dbox_setnumeric(search_box,search_exact_option,exact);
  557.           break;
  558.        default:
  559.           break;
  560.       }
  561.    default:
  562.       break;
  563.    }
  564.   return(FALSE);
  565. }
  566.  
  567. static void iconbar_menuproc(void *handle, char *hit)
  568. {
  569.   handle = handle; 
  570.   switch (hit[0])
  571.   {
  572.   case icon_m_i:
  573.     stdcodes_info();
  574.     break;
  575.   case icon_m_srch:
  576.     window_tidy("search");
  577.     dbox_showstatic(search_box);
  578.     dbox_setfield(search_box,search_entry,"");
  579.     found = 0;
  580.     menu_setflags(save_menu,save_m_s,0,1);
  581.     break;
  582.  
  583.   case icon_m_q:
  584.     if (modified) dbox_showstatic(quit_box);
  585.    else exit(0);
  586.    break;
  587.   }
  588. }
  589. BOOL load_file(char *pathname)
  590. {
  591. /* Check that are not loading the "master" file */
  592.   if (strstr(string_to_lower(pathname),Data_file_name)) if(!initialise) {
  593.     werr(0,"Loading STDcodes again will not be carried out.");
  594.     return TRUE;
  595.     }
  596.   if(initialise) {
  597.   stdstart = stdlast = NULL;
  598.   data_file = file_open(pathname,"r");
  599.   maximum = initial_file_read(data_file,pathname,initialise);
  600. /*  werr(0,"maximum = %d",maximum); */
  601.   file_close(data_file,pathname);
  602.   return TRUE;
  603.   }
  604.   dbox_show(load_box);
  605.   return TRUE;
  606. }
  607. void iconbar_handler(wimp_eventstr *e, void *handle)
  608. {
  609. int filetype;
  610.   e = e;            /* prevent warnings */
  611.   handle = handle;
  612.   if ((filetype = xferrecv_checkinsert(&pathname)) != -1)
  613.     if (load_file(pathname))
  614.       xferrecv_insertfileok();
  615. }
  616. static BOOL make_menus()
  617. {
  618.   if (iconbar_menu = menu_new("STD Codes",">Info,Search,Quit"), iconbar_menu == NULL)
  619.     return FALSE;
  620.   if (search_menu = menu_new("Results","Edit,Save"), search_menu == NULL)
  621.     return FALSE;
  622.   if (save_menu = menu_new("Save",">All,>~Subset"), save_menu == NULL)
  623.     return FALSE;
  624.   if (edit_menu = menu_new("Edit","Add,Delete"), edit_menu == NULL)
  625.     return FALSE;
  626.   menu_submenu(search_menu,1,edit_menu);
  627.   menu_submenu(search_menu,2,save_menu);
  628.   return TRUE;
  629. }
  630. /****************************** INITIALISATION ******************************/
  631. static BOOL std_initialise(void)
  632. {
  633.   wimpt_init("Std Finder");
  634.   res_init("stdfinder");
  635.   resspr_init();
  636.   template_init();
  637.   dbox_init();
  638.  
  639.   search_box = dbox_new("Search");
  640.   dbox_raw_eventhandler(search_box,search_event_handler,0);
  641.  
  642.   edit_box = dbox_new("Edit");
  643.   dbox_raw_eventhandler(edit_box,edit_event_handler,0);
  644.  
  645.   load_box = dbox_new("Load");
  646.   dbox_raw_eventhandler(load_box,load_event_handler,0);
  647.  
  648.   quit_box = dbox_new("Quit");
  649.   dbox_raw_eventhandler(quit_box,quit_event_handler,0);
  650.  
  651.   if (!make_menus()) return FALSE;
  652.  
  653.   baricon("!stdfinder", (int)resspr_area(), stdfinder_iconclick);
  654.   if (!event_attachmenu(win_ICONBAR,iconbar_menu,iconbar_menuproc,0))
  655.     return FALSE;
  656.   
  657.   search_handle = dbox_syshandle(search_box);
  658. /*  if (!event_attachmenu(search_handle,search_menu,search_menuproc,0))
  659.     return FALSE; */
  660.  
  661.   win_register_event_handler(win_ICONBARLOAD, iconbar_handler, 0);
  662.  
  663.   initialise = 1;
  664.   visdelay_begin();
  665.   if (!load_file(Data_file)) return FALSE; /* allow first time */
  666.   visdelay_end();
  667.   srchstart = srchlast = NULL;
  668.   initialise = 0;
  669.  
  670.   return TRUE;
  671. }
  672.  
  673. /******************************* MAIN PROGRAM ********************************/
  674.  
  675. /*--- Main entry point. ---*/
  676. int main()
  677. {
  678.   if (std_initialise())
  679.   {
  680.     while (TRUE)
  681.       event_process();
  682.   }
  683.  
  684.   return 0;
  685. }
  686.